package work;

import java.io.*;

/**
 * @auther Macrydy
 * @date 2020/7/16 19:26
 */
public class CopyUtils {

    public static void copy(String str1,String str2) throws IOException {

        //源文件路径
        File file1 = new File(str1);
        //目标文件路径
        File file2 = new File(str2);

        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file1));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file2));

        byte[] bytes = new byte[1024];
        int len;
        while ((len=bis.read(bytes))!=-1){
            bos.write(bytes,0,len);
        }

        bis.close();
        bos.close();
    }
}
